package rulebase;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.border.LineBorder;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JSpinner;
import java.awt.CardLayout;
import java.awt.event.ActionListener;

public class RuleManagementWindow extends JFrame
{
	private JPanel pnlThree;
	private JPanel pnlFour = new BasicRulePanel();
	private JPanel pnlFive = new SpelloutRulePanel();

	private JComboBox cbxSyntacticCategory;
	private JComboBox cbxRule;
	private JTextField txtGroup;
	private JTextField txtRuleName;
	private JButton btnConstituent;
	private JButton btnSubconstituent;
	private JButton btnNounPhrase;
	private JButton btnVerbPhrase;
	private JButton btnAdjectivePhrase;
	private JButton btnAdverbPhrase;
	private JButton btnCopyFeatures;
	private JButton btnNewTranslation;
	private JButton btnObligatory;
	private JButton btnOptional;
	private JButton btnNotPresent;
	private JButton btnInsertWord;
	private JButton btnCopy;
	private JButton btnMove;
	private JButton btnDelete;
	private JButton btnAddWord;
	private JButton btnAddWords;
	private JButton btnSave;
	private JButton btnCancel;
	private JButton btnStructures;
	private JButton btnFeatures;
	
	public RuleManagementWindow()
	{
		setResizable(false);
		setSize(800,600);
		setLocationRelativeTo(null);
		setVisible(true);
		getContentPane().setLayout(null);
		initGUI();
	}
	
	private void initGUI()
	{
		JPanel pnlOne = new JPanel();
		pnlOne.setBorder(new LineBorder(new Color(0, 0, 0)));
		pnlOne.setBounds(504, 11, 280, 515);
		getContentPane().add(pnlOne);
		pnlOne.setLayout(null);
		
		JPanel pnlTwo = new JPanel();
		pnlTwo.setBorder(new LineBorder(new Color(0, 0, 0)));
		pnlTwo.setBounds(10, 11, 484, 515);
		getContentPane().add(pnlTwo);
		pnlTwo.setLayout(null);
		
		pnlThree = new JPanel();
		pnlThree.setBounds(10, 36, 464, 468);
		pnlTwo.add(pnlThree);
		pnlThree.setLayout(new CardLayout(0, 0));
		
		pnlThree.add(pnlFour,"Basic Rule");
		pnlThree.add(pnlFive, "Spellout Rule");

		JLabel lblSyntacticCategory = new JLabel("Syn Category");
		lblSyntacticCategory.setBounds(10, 11, 93, 14);
		pnlOne.add(lblSyntacticCategory);
		
		JLabel lblGroup = new JLabel("Group");
		lblGroup.setBounds(10, 47, 46, 14);
		pnlOne.add(lblGroup);
		
		JLabel lblRuleName = new JLabel("Rule Name");
		lblRuleName.setBounds(10, 81, 93, 14);
		pnlOne.add(lblRuleName);
		
		JLabel lblRule = new JLabel("Rule");
		lblRule.setBounds(10, 11, 30, 14);
		pnlTwo.add(lblRule);
		
		cbxSyntacticCategory = new JComboBox();
		cbxSyntacticCategory.setBounds(113, 8, 157, 20);
		pnlOne.add(cbxSyntacticCategory);
		
		cbxRule = new JComboBox();
		cbxRule.setBounds(41, 8, 157, 20);
		pnlTwo.add(cbxRule);
		initCbxRuleItems();
		
		txtGroup = new JTextField();
		txtGroup.setBounds(113, 44, 157, 20);
		pnlOne.add(txtGroup);
		txtGroup.setColumns(10);
		
		txtRuleName = new JTextField();
		txtRuleName.setBounds(113, 78, 157, 20);
		pnlOne.add(txtRuleName);
		txtRuleName.setColumns(10);
		
		btnConstituent = new JButton("Const");
		btnConstituent.setBounds(43, 182, 60, 23);
		pnlOne.add(btnConstituent);
		
		btnSubconstituent = new JButton("Subct");
		btnSubconstituent.setBounds(113, 182, 60, 23);
		pnlOne.add(btnSubconstituent);
		
		btnNounPhrase = new JButton("NP");
		btnNounPhrase.setBounds(183, 182, 60, 23);
		pnlOne.add(btnNounPhrase);
		
		btnVerbPhrase = new JButton("VP");
		btnVerbPhrase.setBounds(43, 216, 60, 23);
		pnlOne.add(btnVerbPhrase);
		
		btnAdjectivePhrase = new JButton("Adj");
		btnAdjectivePhrase.setBounds(113, 216, 60, 23);
		pnlOne.add(btnAdjectivePhrase);
		
		btnAdverbPhrase = new JButton("Adv");
		btnAdverbPhrase.setBounds(183, 216, 60, 23);
		pnlOne.add(btnAdverbPhrase);
		
		btnMove = new JButton("Move");
		btnMove.setBounds(43, 250, 60, 23);
		pnlOne.add(btnMove);
		
		btnCopy = new JButton("Copy");
		btnCopy.setBounds(113, 250, 60, 23);
		pnlOne.add(btnCopy);
		
		btnDelete = new JButton("Del");
		btnDelete.setBounds(183, 250, 60, 23);
		pnlOne.add(btnDelete);
		
		btnInsertWord = new JButton("Insert Word");
		btnInsertWord.setBounds(43, 311, 90, 23);
		pnlOne.add(btnInsertWord);
		
		btnAddWords = new JButton("Add Words");
		btnAddWords.setBounds(43, 379, 90, 23);
		pnlOne.add(btnAddWords);
		
		btnAddWord = new JButton("Add Word");
		btnAddWord.setBounds(43, 345, 90, 23);
		pnlOne.add(btnAddWord);
		
		btnNotPresent = new JButton("Not Present");
		btnNotPresent.setBounds(153, 311, 90, 23);
		pnlOne.add(btnNotPresent);
		
		btnOptional = new JButton("Optional");
		btnOptional.setBounds(153, 345, 90, 23);
		pnlOne.add(btnOptional);
		
		btnObligatory = new JButton("Obligatory");
		btnObligatory.setBounds(153, 379, 90, 23);
		pnlOne.add(btnObligatory);
		
		btnCopyFeatures = new JButton("C Features");
		btnCopyFeatures.setBounds(43, 413, 90, 23);
		pnlOne.add(btnCopyFeatures);
		
		btnNewTranslation = new JButton("N Trans");
		btnNewTranslation.setBounds(153, 413, 90, 23);
		pnlOne.add(btnNewTranslation);
		
		btnStructures = new JButton("Structures");
		btnStructures.setBounds(43, 131, 89, 23);
		pnlOne.add(btnStructures);
		
		btnFeatures = new JButton("Features");
		btnFeatures.setBounds(154, 131, 89, 23);
		pnlOne.add(btnFeatures);
		
		btnSave = new JButton("Save");
		btnSave.setBounds(546, 537, 89, 23);
		getContentPane().add(btnSave);
		
		btnCancel = new JButton("Cancel");
		btnCancel.setBounds(668, 537, 89, 23);
		getContentPane().add(btnCancel);
		
		initCbxSyntacticCategoryItems();
	}
	
	private void initCbxRuleItems()
	{
		DefaultComboBoxModel cbxModel = new DefaultComboBoxModel();
		cbxModel.addElement("Basic Rule");
		cbxModel.addElement("Spellout Rule");
		cbxRule.setModel(cbxModel);
	}
	
	private void initCbxSyntacticCategoryItems()
	{
		DefaultComboBoxModel cbxModel = new DefaultComboBoxModel();
		cbxModel.addElement("Noun");
		cbxModel.addElement("Verb");
		cbxModel.addElement("Adjective");
		cbxModel.addElement("Adposition");
		cbxModel.addElement("Conjunction");
		cbxModel.addElement("Pronoun");
		cbxModel.addElement("Particle");
		cbxModel.addElement("Noun Phrase");
		cbxModel.addElement("Verb Phrase");
		cbxModel.addElement("Adjective Phrase");
		cbxModel.addElement("Adverb Phrase");
		cbxModel.addElement("Clause");
		cbxSyntacticCategory.setModel(cbxModel);
	}
	
	public String getCbxRuleSelectedItem()
	{
		return (String) cbxRule.getSelectedItem();
	}
	
	public void setCbxRuleSelectedItem(String s)
	{
		cbxRule.setSelectedItem(s);
	}
	
	public JPanel getPnlThree() 
	{
		return pnlThree;
	}

	public void setPnlThree(JPanel pnlThree) 
	{
		this.pnlThree = pnlThree;
	}
	
	public JPanel getPnlFour() 
	{
		return pnlFour;
	}

	public void setPnlFour(JPanel pnlFour) 
	{
		this.pnlFour = pnlFour;
	}

	public JPanel getPnlFive()
	{
		return pnlFive;
	}

	public void setPnlFive(JPanel pnlFive) 
	{
		this.pnlFive = pnlFive;
	}
	
	public void setConstituentListener(ActionListener AL)
	{
		btnConstituent.addActionListener((AL));
	}
	
	public void setSubconstituentListener(ActionListener AL)
	{
		btnSubconstituent.addActionListener((AL));
	}
	
	public void setNounPhraseListener(ActionListener AL)
	{
		btnNounPhrase.addActionListener((AL));
	}
	
	public void setVerbPhraseListener(ActionListener AL)
	{
		btnVerbPhrase.addActionListener((AL));
	}
	
	public void setAdjectivePhraseListener(ActionListener AL)
	{
		btnAdjectivePhrase.addActionListener((AL));
	}
	
	public void setAdverbPhraseListener(ActionListener AL)
	{
		btnAdverbPhrase.addActionListener((AL));
	}
	
	public void setCopyFeaturesListener(ActionListener AL)
	{
		btnCopyFeatures.addActionListener((AL));
	}
	
	public void setNewTranslationListener(ActionListener AL)
	{
		btnNewTranslation.addActionListener((AL));
	}
	
	public void setObligatoryListener(ActionListener AL)
	{
		btnObligatory.addActionListener((AL));
	}
	
	public void setOptionalListener(ActionListener AL)
	{
		btnOptional.addActionListener((AL));
	}
	
	public void setNotPresentListener(ActionListener AL)
	{
		btnNotPresent.addActionListener((AL));
	}
	
	public void setInsertWordListener(ActionListener AL)
	{
		btnInsertWord.addActionListener((AL));
	}
	
	public void setCopyListener(ActionListener AL)
	{
		btnCopy.addActionListener((AL));
	}
	
	public void setMoveListener(ActionListener AL)
	{
		btnMove.addActionListener((AL));
	}
	
	public void setDeleteListener(ActionListener AL)
	{
		btnDelete.addActionListener((AL));
	}
	
	public void setAddWordListener(ActionListener AL)
	{
		btnAddWord.addActionListener((AL));
	}
	
	public void setAddWordsListener(ActionListener AL)
	{
		btnAddWords.addActionListener((AL));
	}
	
	public void setSaveListener(ActionListener AL)
	{
		btnSave.addActionListener((AL));
	}
	
	public void setCancelListener(ActionListener AL)
	{
		btnCancel.addActionListener((AL));
	}
	
	public void setGroupListener(ActionListener AL)
	{
		txtGroup.addActionListener((AL));
	}
	
	public void setRuleNameListener(ActionListener AL)
	{
		txtRuleName.addActionListener((AL));
	}
	
	public void setCbxSyntacticCategoryListener(ActionListener AL)
	{
		cbxSyntacticCategory.addActionListener((AL));
	}
	public void setCbxRuleListener(ActionListener AL)
	{
		cbxRule.addActionListener((AL));
	}
	
	public void setFeaturesListener(ActionListener AL)
	{
		btnFeatures.addActionListener(AL);
	}
	
	public String getCbxSyntacticCategoryItem()
	{
		return (String)cbxSyntacticCategory.getSelectedItem();
	}
	
	public String getRuleNameText()
	{
		return txtRuleName.getText();
	}
	
	public String getGroupText()
	{
		return txtGroup.getText();
	}
	
	public void setRuleNameText(String s)
	{
		txtRuleName.setText(s);
	}
	
	public void setGroupText(String s)
	{
		txtGroup.setText(s);
	}

}
